data =  data)
main_med.out_EffInter <- mediate(med.fit_EffInter, out.fit_EffInter, treat = "intersectional_bias", mediator = "representation_femaleNonwhite",
sims = 10000, boot = TRUE,
boot.ci.type = "bca")
## specific electability --------------------------
med.fit_SpElecFem <- lm(representation_female ~ gender_bias + age  + gender + ideology + party_vote +se_use,
data = data )
out.fit_SpElecFem <- lm(chance_female ~ gender_bias + age  + gender + ideology + representation_female +party_vote + se_use,
data =  data)
main_med.out_SpElecFem <- mediate(med.fit_SpElecFem, out.fit_SpElecFem, treat = "gender_bias", mediator = "representation_female",
sims = 10000, boot = TRUE,
boot.ci.type = "bca")
# nonwhite
med.fit_SpElecNonWhite <- lm(representation_nonwhite ~ race_bias + age  + gender + ideology + party_vote +se_use,
data = data )
out.fit_SpElectNonWhite <- lm(chance_nonwhite ~ race_bias + age  + gender + ideology + representation_nonwhite +party_vote + se_use,
data =  data)
main_med.out_SpElecNonWhite <- mediate(med.fit_SpElecNonWhite, out.fit_SpElectNonWhite, treat = "race_bias", mediator = "representation_nonwhite",
sims = 10000, boot = TRUE,
boot.ci.type = "bca")
#intersectional bias
med.fit_SpElecInter <- lm(representation_femaleNonwhite ~ intersectional_bias + age  + gender + ideology + party_vote +se_use,
data = data )
out.fit_SpElecInter <- lm(chance_nonwhiteFemale ~ intersectional_bias + age  + gender + ideology + representation_femaleNonwhite +party_vote + se_use,
data =  data)
main_med.out_SpElecInter <- mediate(med.fit_SpElecInter, out.fit_SpElecInter, treat = "intersectional_bias", mediator = "representation_femaleNonwhite",
sims = 10000, boot = TRUE,
boot.ci.type = "bca")
# generate output tables for the appendix for the main models
# reproduce upper part Table C4.2.1
tab_model(med.fit_EffFem,
out.fit_ElecFem, out.fit_EffFem, out.fit_SpElecFem,
file = "outputs/Study4_TableC4.2.1_MediationGenderBias.doc")
# reproduce upper part Table C4.2.2
tab_model(med.fit_EffNonWhite,
out.fit_ElecNonWhite, out.fit_EffNonWhite, out.fit_SpElectNonWhite,
file = "outputs/Study4_TableC4.2.2_MediationRaceBias.doc")
# reproduce upper part Table C4.2.3
tab_model(med.fit_EffInter,
out.fit_ElecInter, out.fit_EffInter, out.fit_SpElecInter,
file = "outputs/Study4_TableC4.2.3_MediationIntersectionalBias.doc")
# Conduct additional mediation_analyses --------------
#In the following, we conduct all combinations of mediation models
# on different subsamples. The data is then combined into a
# single data frame which is the basis for visualization.
#
# Note that the "mediation" library is quite vulnerable to bugs when
# naming/referencing objects within loops/functions, which is why
# we spell out the code for each model and then summarize all
# mediation models with a function.
###### FEMALE subsample ---------------------------------------------
#Note we remove gender as a covariate
data_female <- data %>% filter(gender == "female")
## general electability
med.fit <- lm(representation_female ~ gender_bias + age   + ideology + party_vote +se_use,
data = data_female )
out.fit <- lm(viability_female ~ gender_bias + age   + ideology + representation_female +party_vote + se_use,
data = data_female)
female_med.out_ElecFem <- mediate(med.fit, out.fit, treat = "gender_bias", mediator = "representation_female",
sims = 10000, boot = TRUE,
boot.ci.type = "bca")
# nonwhite
med.fit <- lm(representation_nonwhite ~ race_bias + age   + ideology + party_vote +se_use,
data = data_female )
out.fit <- lm(viability_nonwhite ~ race_bias + age   + ideology + representation_nonwhite +party_vote + se_use,
data = data_female)
female_med.out_ElecNonWhite <- mediate(med.fit, out.fit, treat = "race_bias", mediator = "representation_nonwhite",
sims = 10000, boot = TRUE,
boot.ci.type = "bca")
#intersectonal bias
med.fit <- lm(representation_femaleNonwhite ~ intersectional_bias + age   + ideology + party_vote +se_use,
data = data_female )
out.fit <- lm(viability_femaleNonwhite ~ intersectional_bias + age   + ideology + representation_femaleNonwhite +party_vote + se_use,
data = data_female)
female_med.out_ElecInter <- mediate(med.fit, out.fit, treat = "intersectional_bias", mediator = "representation_femaleNonwhite",
sims = 10000, boot = TRUE,
boot.ci.type = "bca")
# external efficacy
med.fit <- lm(representation_female ~ gender_bias + age   + ideology + party_vote +se_use,
data = data_female )
out.fit <- lm(efficacy ~ gender_bias + age   + ideology + representation_female +party_vote + se_use,
data = data_female)
female_med.out_EffFem <- mediate(med.fit, out.fit, treat = "gender_bias", mediator = "representation_female",
sims = 10000, boot = TRUE,
boot.ci.type = "bca")
# nonwhite
med.fit <- lm(representation_nonwhite ~ race_bias + age   + ideology + party_vote +se_use,
data = data_female )
out.fit <- lm(efficacy ~ race_bias + age   + ideology + representation_nonwhite +party_vote + se_use,
data = data_female)
female_med.out_EffNonWhite <- mediate(med.fit, out.fit, treat = "race_bias", mediator = "representation_nonwhite",
sims = 10000, boot = TRUE,
boot.ci.type = "bca")
#intersectonal bias
med.fit <- lm(representation_femaleNonwhite ~ intersectional_bias + age   + ideology + party_vote +se_use,
data = data_female )
out.fit <- lm(efficacy ~ intersectional_bias + age   + ideology + representation_femaleNonwhite +party_vote + se_use,
data = data_female)
female_med.out_EffInter <- mediate(med.fit, out.fit, treat = "intersectional_bias", mediator = "representation_femaleNonwhite",
sims = 10000, boot = TRUE,
boot.ci.type = "bca")
## specific electability
med.fit <- lm(representation_female ~ gender_bias + age   + ideology + party_vote +se_use,
data = data_female )
out.fit <- lm(chance_female ~ gender_bias + age   + ideology + representation_female +party_vote + se_use,
data = data_female)
female_med.out_SpElecFem <- mediate(med.fit, out.fit, treat = "gender_bias", mediator = "representation_female",
sims = 10000, boot = TRUE,
boot.ci.type = "bca")
# nonwhite
med.fit <- lm(representation_nonwhite ~ race_bias + age   + ideology + party_vote +se_use,
data = data_female )
out.fit <- lm(chance_nonwhite ~ race_bias + age   + ideology + representation_nonwhite +party_vote + se_use,
data = data_female)
female_med.out_SpElecNonWhite <- mediate(med.fit, out.fit, treat = "race_bias", mediator = "representation_nonwhite",
sims = 10000, boot = TRUE,
boot.ci.type = "bca")
#intersectional bias
med.fit <- lm(representation_femaleNonwhite ~ intersectional_bias + age   + ideology + party_vote +se_use,
data = data_female )
out.fit <- lm(chance_nonwhiteFemale ~ intersectional_bias + age   + ideology + representation_femaleNonwhite +party_vote + se_use,
data = data_female)
female_med.out_SpElecInter <- mediate(med.fit, out.fit, treat = "intersectional_bias", mediator = "representation_femaleNonwhite",
sims = 10000, boot = TRUE,
boot.ci.type = "bca")
###### MALE subsample ---------------------------------------------
#Note we remove gender as a covariate
data_male <- data %>% filter(gender == "male")
## general electability
med.fit <- lm(representation_female ~ gender_bias + age   + ideology + party_vote +se_use,
data = data_male )
out.fit <- lm(viability_female ~ gender_bias + age   + ideology + representation_female +party_vote + se_use,
data = data_male)
male_med.out_ElecFem <- mediate(med.fit, out.fit, treat = "gender_bias", mediator = "representation_female",
sims = 10000, boot = TRUE,
boot.ci.type = "bca")
# nonwhite
med.fit <- lm(representation_nonwhite ~ race_bias + age   + ideology + party_vote +se_use,
data = data_male )
out.fit <- lm(viability_nonwhite ~ race_bias + age   + ideology + representation_nonwhite +party_vote + se_use,
data = data_male)
male_med.out_ElecNonWhite <- mediate(med.fit, out.fit, treat = "race_bias", mediator = "representation_nonwhite",
sims = 10000, boot = TRUE,
boot.ci.type = "bca")
#intersectonal bias
med.fit <- lm(representation_femaleNonwhite ~ intersectional_bias + age   + ideology + party_vote +se_use,
data = data_male )
out.fit <- lm(viability_femaleNonwhite ~ intersectional_bias + age   + ideology + representation_femaleNonwhite +party_vote + se_use,
data = data_male)
male_med.out_ElecInter <- mediate(med.fit, out.fit, treat = "intersectional_bias", mediator = "representation_femaleNonwhite",
sims = 10000, boot = TRUE,
boot.ci.type = "bca")
# external efficacy
med.fit <- lm(representation_female ~ gender_bias + age   + ideology + party_vote +se_use,
data = data_male )
out.fit <- lm(efficacy ~ gender_bias + age   + ideology + representation_female +party_vote + se_use,
data = data_male)
male_med.out_EffFem <- mediate(med.fit, out.fit, treat = "gender_bias", mediator = "representation_female",
sims = 10000, boot = TRUE,
boot.ci.type = "bca")
# nonwhite
med.fit <- lm(representation_nonwhite ~ race_bias + age   + ideology + party_vote +se_use,
data = data_male )
out.fit <- lm(efficacy ~ race_bias + age   + ideology + representation_nonwhite +party_vote + se_use,
data = data_male)
male_med.out_EffNonWhite <- mediate(med.fit, out.fit, treat = "race_bias", mediator = "representation_nonwhite",
sims = 10000, boot = TRUE,
boot.ci.type = "bca")
#intersectonal bias
med.fit <- lm(representation_femaleNonwhite ~ intersectional_bias + age   + ideology + party_vote +se_use,
data = data_male )
out.fit <- lm(efficacy ~ intersectional_bias + age   + ideology + representation_femaleNonwhite +party_vote + se_use,
data = data_male)
male_med.out_EffInter <- mediate(med.fit, out.fit, treat = "intersectional_bias", mediator = "representation_femaleNonwhite",
sims = 10000, boot = TRUE,
boot.ci.type = "bca")
## specific electability
med.fit <- lm(representation_female ~ gender_bias + age   + ideology + party_vote +se_use,
data = data_male )
out.fit <- lm(chance_female ~ gender_bias + age   + ideology + representation_female +party_vote + se_use,
data = data_male)
male_med.out_SpElecFem <- mediate(med.fit, out.fit, treat = "gender_bias", mediator = "representation_female",
sims = 10000, boot = TRUE,
boot.ci.type = "bca")
# nonwhite
med.fit <- lm(representation_nonwhite ~ race_bias + age   + ideology + party_vote +se_use,
data = data_male )
out.fit <- lm(chance_nonwhite ~ race_bias + age   + ideology + representation_nonwhite +party_vote + se_use,
data = data_male)
male_med.out_SpElecNonWhite <- mediate(med.fit, out.fit, treat = "race_bias", mediator = "representation_nonwhite",
sims = 10000, boot = TRUE,
boot.ci.type = "bca")
#intersectional bias
med.fit <- lm(representation_femaleNonwhite ~ intersectional_bias + age   + ideology + party_vote +se_use,
data = data_male )
out.fit <- lm(chance_nonwhiteFemale ~ intersectional_bias + age   + ideology + representation_femaleNonwhite +party_vote + se_use,
data = data_male)
male_med.out_SpElecInter <- mediate(med.fit, out.fit, treat = "intersectional_bias", mediator = "representation_femaleNonwhite",
sims = 10000, boot = TRUE,
boot.ci.type = "bca")
######  DEMOCRAT subsample ---------------------------------------------
#Note we remove party_vote as a covariate
data_democratic <- data %>% filter(party_vote == "liberal")
## general electability
med.fit <- lm(representation_female ~ gender_bias + age   + ideology + gender +se_use,
data = data_democratic )
out.fit <- lm(viability_female ~ gender_bias + age   + ideology + representation_female +gender + se_use,
data = data_democratic)
democratic_med.out_ElecFem <- mediate(med.fit, out.fit, treat = "gender_bias", mediator = "representation_female",
sims = 100, boot = TRUE,
boot.ci.type = "bca")
# nonwhite
med.fit <- lm(representation_nonwhite ~ race_bias + age   + ideology + gender +se_use,
data = data_democratic )
out.fit <- lm(viability_nonwhite ~ race_bias + age   + ideology + representation_nonwhite +gender + se_use,
data = data_democratic)
democratic_med.out_ElecNonWhite <- mediate(med.fit, out.fit, treat = "race_bias", mediator = "representation_nonwhite",
sims = 10000, boot = TRUE,
boot.ci.type = "bca")
#intersectonal bias
med.fit <- lm(representation_femaleNonwhite ~ intersectional_bias + age   + ideology + gender +se_use,
data = data_democratic )
out.fit <- lm(viability_femaleNonwhite ~ intersectional_bias + age   + ideology + representation_femaleNonwhite +gender + se_use,
data = data_democratic)
democratic_med.out_ElecInter <- mediate(med.fit, out.fit, treat = "intersectional_bias", mediator = "representation_femaleNonwhite",
sims = 10000, boot = TRUE,
boot.ci.type = "bca")
# external efficacy
med.fit <- lm(representation_female ~ gender_bias + age   + ideology + gender +se_use,
data = data_democratic )
out.fit <- lm(efficacy ~ gender_bias + age   + ideology + representation_female +gender + se_use,
data = data_democratic)
democratic_med.out_EffFem <- mediate(med.fit, out.fit, treat = "gender_bias", mediator = "representation_female",
sims = 10000, boot = TRUE,
boot.ci.type = "bca")
# nonwhite
med.fit <- lm(representation_nonwhite ~ race_bias + age   + ideology + gender +se_use,
data = data_democratic )
out.fit <- lm(efficacy ~ race_bias + age   + ideology + representation_nonwhite +gender + se_use,
data = data_democratic)
democratic_med.out_EffNonWhite <- mediate(med.fit, out.fit, treat = "race_bias", mediator = "representation_nonwhite",
sims = 10000, boot = TRUE,
boot.ci.type = "bca")
#intersectonal bias
med.fit <- lm(representation_femaleNonwhite ~ intersectional_bias + age   + ideology + gender +se_use,
data = data_democratic )
out.fit <- lm(efficacy ~ intersectional_bias + age   + ideology + representation_femaleNonwhite +gender + se_use,
data = data_democratic)
democratic_med.out_EffInter <- mediate(med.fit, out.fit, treat = "intersectional_bias", mediator = "representation_femaleNonwhite",
sims = 10000, boot = TRUE,
boot.ci.type = "bca")
## specific electability
med.fit <- lm(representation_female ~ gender_bias + age   + ideology + gender +se_use,
data = data_democratic )
out.fit <- lm(chance_female ~ gender_bias + age   + ideology + representation_female +gender + se_use,
data = data_democratic)
democratic_med.out_SpElecFem <- mediate(med.fit, out.fit, treat = "gender_bias", mediator = "representation_female",
sims = 10000, boot = TRUE,
boot.ci.type = "bca")
# nonwhite
med.fit <- lm(representation_nonwhite ~ race_bias + age   + ideology + gender +se_use,
data = data_democratic )
out.fit <- lm(chance_nonwhite ~ race_bias + age   + ideology + representation_nonwhite +gender + se_use,
data = data_democratic)
democratic_med.out_SpElecNonWhite <- mediate(med.fit, out.fit, treat = "race_bias", mediator = "representation_nonwhite",
sims = 10000, boot = TRUE,
boot.ci.type = "bca")
#intersectional bias
med.fit <- lm(representation_femaleNonwhite ~ intersectional_bias + age   + ideology + gender +se_use,
data = data_democratic )
out.fit <- lm(chance_nonwhiteFemale ~ intersectional_bias + age   + ideology + representation_femaleNonwhite +gender + se_use,
data = data_democratic)
democratic_med.out_SpElecInter <- mediate(med.fit, out.fit, treat = "intersectional_bias", mediator = "representation_femaleNonwhite",
sims = 10000, boot = TRUE,
boot.ci.type = "bca")
######  REPUBLICAN subsample ---------------------------------------------
#Note we remove party_vote as a covariate
data_republican <- data %>% filter(party_vote == "conservative" &
gender != "other")
## general electability
med.fit <- lm(representation_female ~ gender_bias + age   + ideology + gender +se_use,
data = data_republican )
out.fit <- lm(viability_female ~ gender_bias + age   + ideology + representation_female +gender + se_use,
data = data_republican)
republican_med.out_ElecFem <- mediate(med.fit, out.fit, treat = "gender_bias", mediator = "representation_female",
sims = 10000, boot = TRUE,
boot.ci.type = "bca")
# nonwhite
med.fit <- lm(representation_nonwhite ~ race_bias + age   + ideology + gender +se_use,
data = data_republican )
out.fit <- lm(viability_nonwhite ~ race_bias + age   + ideology + representation_nonwhite +gender + se_use,
data = data_republican)
republican_med.out_ElecNonWhite <- mediate(med.fit, out.fit, treat = "race_bias", mediator = "representation_nonwhite",
sims = 10000, boot = TRUE,
boot.ci.type = "bca")
#intersectonal bias
med.fit <- lm(representation_femaleNonwhite ~ intersectional_bias + age   + ideology + gender +se_use,
data = data_republican )
out.fit <- lm(viability_femaleNonwhite ~ intersectional_bias + age   + ideology + representation_femaleNonwhite +gender + se_use,
data = data_republican)
republican_med.out_ElecInter <- mediate(med.fit, out.fit, treat = "intersectional_bias", mediator = "representation_femaleNonwhite",
sims = 10000, boot = TRUE,
boot.ci.type = "bca")
# external efficacy
med.fit <- lm(representation_female ~ gender_bias + age   + ideology + gender +se_use,
data = data_republican )
out.fit <- lm(efficacy ~ gender_bias + age   + ideology + representation_female +gender + se_use,
data = data_republican)
republican_med.out_EffFem <- mediate(med.fit, out.fit, treat = "gender_bias", mediator = "representation_female",
sims = 10000, boot = TRUE,
boot.ci.type = "bca")
# nonwhite
med.fit <- lm(representation_nonwhite ~ race_bias + age   + ideology + gender +se_use,
data = data_republican )
out.fit <- lm(efficacy ~ race_bias + age   + ideology + representation_nonwhite +gender + se_use,
data = data_republican)
republican_med.out_EffNonWhite <- mediate(med.fit, out.fit, treat = "race_bias", mediator = "representation_nonwhite",
sims = 10000, boot = TRUE,
boot.ci.type = "bca")
#intersectonal bias
med.fit <- lm(representation_femaleNonwhite ~ intersectional_bias + age   + ideology + gender +se_use,
data = data_republican )
out.fit <- lm(efficacy ~ intersectional_bias + age   + ideology + representation_femaleNonwhite +gender + se_use,
data = data_republican)
republican_med.out_EffInter <- mediate(med.fit, out.fit, treat = "intersectional_bias", mediator = "representation_femaleNonwhite",
sims = 10000, boot = TRUE,
boot.ci.type = "bca")
## specific electability
med.fit <- lm(representation_female ~ gender_bias + age   + ideology + gender +se_use,
data = data_republican )
out.fit <- lm(chance_female ~ gender_bias + age   + ideology + representation_female +gender + se_use,
data = data_republican)
republican_med.out_SpElecFem <- mediate(med.fit, out.fit, treat = "gender_bias", mediator = "representation_female",
sims = 10000, boot = TRUE,
boot.ci.type = "bca")
# nonwhite
med.fit <- lm(representation_nonwhite ~ race_bias + age   + ideology + gender +se_use,
data = data_republican )
out.fit <- lm(chance_nonwhite ~ race_bias + age   + ideology + representation_nonwhite +gender + se_use,
data = data_republican)
republican_med.out_SpElecNonWhite <- mediate(med.fit, out.fit, treat = "race_bias", mediator = "representation_nonwhite",
sims = 10000, boot = TRUE,
boot.ci.type = "bca")
#intersectional bias
med.fit <- lm(representation_femaleNonwhite ~ intersectional_bias + age   + ideology + gender +se_use,
data = data_republican )
out.fit <- lm(chance_nonwhiteFemale ~ intersectional_bias + age   + ideology + representation_femaleNonwhite +gender + se_use,
data = data_republican)
republican_med.out_SpElecInter <- mediate(med.fit, out.fit, treat = "intersectional_bias", mediator = "representation_femaleNonwhite",
sims = 10000, boot = TRUE,
boot.ci.type = "bca")
# Save an image of the data for future use so the models don't
# have to be re-run every time.
# Note that the main models from the section H4 should also have been run at this point
save.image(file = "outputs/Study4_AllMediationModels.RData")
# Visualization: Figure 6 ------------------------------------
# There are two ways to get the data for Figure 6.
# 1. Run all the mediation models in this script. This takes a while
# 2. Load the saved R image from the outputs.
# Either way, we first need to extract the results from the mediation models
# with the following function/loop
##### Gather results of mediation analyses ---------------
# Initialize an empty list to store the results
results_list <- list()
# Loop through all objects in the R environment
for (obj_name in ls()) {
# Check if the object name contains "_med.out_"
if (grepl("_med.out_", obj_name)) {
# Get the mediation object by name using get()
med_out <- get(obj_name)
# Extract the necessary information
acme <- med_out$d.avg
ci.lower <- med_out$d.avg.ci[1]
ci.upper <- med_out$d.avg.ci[2]
# Store the information in a list
results_list[[length(results_list) + 1]] <- data.frame(
model_name = obj_name,
acme = acme,
ci.lower = ci.lower,
ci.upper = ci.upper,
stringsAsFactors = FALSE
)
}
}
# Combine all the data frames in the results_list into one data frame
results_df <- do.call(rbind, results_list)
# do some data manipulation to get clean variables for visualization
med_data <- results_df %>%
separate(
model_name,
into = c("sample", "trash", "descriptor"), # Names for the new variables
sep = "_",  # Separator (underscore)
extra = "merge",  # To handle cases where there might be more than 3 parts
fill = "right")%>%  # Fill with NA if there are fewer than 3 parts
mutate(
condition = case_when(
grepl("Fem", descriptor) ~ "Gender bias",
grepl("NonWhite", descriptor) ~ "Race bias",
grepl("Inter", descriptor) ~ "Double bias",
TRUE ~ NA_character_  # Fallback in case none of the conditions are met
),
outcome = case_when(
grepl("Eff", descriptor) ~ "External efficacy",
grepl("SpElec", descriptor) ~ "Specific electability",
grepl("Elec", descriptor) & !grepl("SpElec", descriptor) ~ "General electability",
TRUE ~ NA_character_  # Fallback in case none of the conditions are met
),
is_full_sample = case_when(
sample == "main" ~ "yes",
sample != "main" ~ "no"
),
sample = fct_recode(sample,
"Full" = "main",
"Male respondents" = "male",
"Female respondents" = "female",
"Republicans" = "republican",
"Democrats" = "democratic"),
sample = fct_relevel(sample,
"Democrats", "Republicans",
"Female respondents","Male respondents",
"Full"),
condition = fct_relevel(condition,
"Gender bias","Race bias","Double bias"),
outcome = fct_relevel(outcome,
"General electability","Specific electability","External efficacy"),
acme = round(acme, 3))
Figure6 <- med_data %>%
ggplot(aes(
y = sample, x = acme, xmin = ci.lower, xmax = ci.upper,
col = is_full_sample)) +
geom_vline(xintercept = 0, linetype = "dashed")+
geom_pointrange()+
geom_text(data = filter(med_data, is_full_sample == "yes"),
aes(label = acme),  size = 2.5,
vjust = -0.73, color = "black")+
facet_grid(condition ~ outcome, switch = "y") +
theme_classic() +
coord_flex_cart(left = capped_vertical("both")) +
scale_color_manual(
values = c("grey60","#3b528b"))+
labs(y = "", x = "",
title = "")+
theme(
legend.position = "bottom",
strip.text.x = element_text(
size = 12, face = "bold"),
strip.text.y = element_text(
face = "bold"),
strip.background = element_blank())+
# theme(panel.spacing = unit(2, "lines")) +
guides(color = "none")
ggsave(Figure6, filename = "outputs/Study4_Figure6.jpeg", dpi = 800,
width = 7, height = 6)
# 0 - Data preparation ----------------------
#libraries
library(tidyverse) # for tidy data manipulations
library(lme4) # For multilevel models
library(lmerTest) # for multilevel models
library(marginaleffects) # extracting results from multilevel models
library(sjPlot) # exporting regression results
library(sjmisc) #exporting regresion resuls
library(psych) # for corr.test()
library(officer) # for printing out tables
library(ggplot2)
library(ggrepel)
library(ggdist)
library(viridis)
library(lemon)
# 0 - Data preparation ----------------------
#libraries
library(tidyverse) # for tidy data manipulations
library(lme4) # For multilevel models
library(lmerTest) # for multilevel models
library(marginaleffects) # extracting results from multilevel models
library(sjPlot) # exporting regression results
library(sjmisc) #exporting regresion resuls
library(psych) # for corr.test()
library(ggrepel)
library(ggplot2)
library(ggpmisc)
library(gghighlight)
library(countrycode)
library(cowplot)
library(lemon)
# 0 - Data preparation ----------------------
#libraries
library(tidyverse) # for tidy data manipulations
library(lme4) # For multilevel models
library(lmerTest) # for multilevel models
library(marginaleffects) # extracting results from multilevel models
library(sjPlot) # exporting regression results
library(sjmisc) #exporting regresion resuls
library(mediation) # for mediation analysis (H4)
library(viridis)
library(gghighlight)
library(Hmisc)
library(lemon)
library
# 0 - Data preparation ----------------------
#libraries
library(tidyverse) # for tidy data manipulations
library(lme4) # For multilevel models
library(lmerTest) # for multilevel models
library(marginaleffects) # extracting results from multilevel models
library(sjPlot) # exporting regression results
library(sjmisc) #exporting regresion resuls
library(mediation) # for mediation analysis (H4)
library(emmeans)
library(rstatix)
library(broom)
library(officer)
sessionInfo()
